
/**
 * 返回帖子距离现在多少时间
 * @param  {String}     待格式化的时间
 * @return {String}     返回的时间
 */
export const leaveDay = (Time) =>{

       let time = Date.parse(new Date(Time));
       let now = Date.parse(new Date()); 
       let remainTime = now - time;
       if(remainTime<0){
       	  return '';
       }else if(remainTime / 1000 < 60){
       	  return parseInt(remainTime / 1000)+'秒前';
       }else if(remainTime / 1000 / 60< 60){
       	  return parseInt(remainTime / 60000)+'分钟前';
       }else if(remainTime / 1000 / 60 / 60 < 24){
       	  return parseInt(remainTime / 1000 / 60 / 60)+'小时前';
       }else if(remainTime / 1000 / 60 / 60 / 24 < 31){
       	  return parseInt(remainTime / 1000 / 60 / 60 / 24)+'天前';
       }else if(remainTime / 1000 / 60 / 60 / 24 / 30< 12){
       	  return parseInt(remainTime / 1000 / 60 / 60 / 24 / 30)+'个月前';
       }else if(remainTime / 1000 / 60 / 60 / 24 / 30 / 12){
       	  return parseInt(remainTime / 1000 / 60 / 60 / 24 / 30 / 12)+'年前';
       }

}


/**
 * 将2017-12-18T13:24:13.334Z格式的时间转化成2017-12-18 13:24:13
 * @param  {String}  待格式化的时间
 * @return {String}  返回的时间
 */
export const parseTime = (Time) =>{

       return Time.replace(/T/g,' ').replace(/\.[\d]{3}Z/,'');
}

